package com.yang.net.ip;

import sun.applet.Main;

import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.net.UnknownHostException;

/**
 * @author yds
 * @program net-sokect_stduy
 * @description java net下的ip操作类
 * @create 2020-09-27 14:25
 **/
public class TestInetAddress {
    public static void main(String[] args) {
        try {
            InetAddress local = InetAddress.getByName("127.0.0.1");//获取当前域名的InetAddress对象
            InetAddress local1 = InetAddress.getByName("www.baidu.com");
            InetAddress[] local2 = InetAddress.getAllByName("www.baidu.com");
            InetAddress  local3 = InetAddress.getLocalHost();
            System.out.println(local);
            System.out.println(local1);
            System.out.println(local3);
            for (int i = 0; i < local2.length; i++) {
                System.out.println(local2[i]);
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

    }

}